var proxy = require('http-proxy-middleware');
var URL = require('url');
var XLSX = require('xlsx');
var proxyPlugin = require('express-formidable');

var proxyMiddleWare;
if (process.env.NODE_ENV === 'production') {
    proxyMiddleWare = proxyPlugin({uploadDir: '/tmp'})
} else {
    proxyMiddleWare = proxyPlugin()
}

module.exports = function (app) {
    // 反向代理
    let proxyTarget = 'http://service-mq8w23ev-1254112020.bj.apigw.tencentcs.com/test';
    app.use('/api', proxy.createProxyMiddleware ({
        target: proxyTarget,
        changeOrigin: true,
        pathRewrite: {
            '^/api': ''
        }
    }));
}